home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / FlyThrough 1.1.2 / src / Source / QD3D General Tools / CQD3DPane.h < prev    next >
Encoding:
Text File  |  1997-03-17  |  4.0 KB  |  122 lines  |  [TEXT/CWIE]

  1. //
  2. //    CQD3DPane.h
  3. //
  4. //    class CQD3DPane
  5. //    A Pane for rendering a QuickDraw 3D view.
  6. //
  7. //    by James Jennings
  8. //    Started November 21, 1995
  9. //
  10. //    New Strategy, June 25, 1996
  11. //        Rather than make this class abstract, make it always usable.
  12. //        When the mModel (or whatever) isn't available, 
  13. //        display using some reasonable default.
  14. //        We add the missing pieces with SetModel() (or whatever.)
  15. //
  16. //        Internal objects will all be made on demand so they might be set first
  17. //        without having to destroy the old version.
  18. //
  19. //    Note: Since "Erase on Update" is on, you must call Draw(nil) rather than Refresh()
  20. //        or else you'll get some nasty flickering.
  21. //
  22.  
  23. #pragma once
  24.  
  25. #include <LPane.h>
  26. #include <QD3DView.h>
  27. #include <QD3DShader.h>
  28.  
  29. class CQD3DPane : public LPane {
  30.     friend class StSubmittingSetter;
  31. public:
  32.     enum { class_ID = 'Q3pn' };
  33.     // This is an abstract class: we can't create it directly from a stream.
  34.     static CQD3DPane*    CreateFromStream(LStream *inStream);
  35.     static    void    Register(void)
  36.         {     URegistrar::RegisterClass(CQD3DPane::class_ID,    
  37.             (ClassCreatorFunc) CQD3DPane::CreateFromStream);  }
  38.     
  39.                     CQD3DPane();
  40.                     CQD3DPane(const CQD3DPane &inOriginal);        
  41.                     CQD3DPane(LStream *inStream);
  42.     
  43.     virtual            ~CQD3DPane();
  44.  
  45.     virtual void            RebuildView();
  46.     
  47.     virtual TQ3StyleObject    GetInterpolation();
  48.     virtual TQ3StyleObject    GetBackFacing();
  49.     virtual TQ3StyleObject    GetFill();
  50.     
  51.     virtual TQ3DrawContextObject     GetDrawContext(void);
  52.     virtual void                    SetClearImageColor(const TQ3ColorARGB &inColor);
  53.     virtual void                    GetClearImageColor(TQ3ColorARGB &outColor);
  54.     
  55.     virtual void                SetRenderer(TQ3RendererObject inRenderer);
  56.     virtual TQ3RendererObject     GetRenderer(void);
  57.     virtual void                SetModel( TQ3GroupObject inGroup );
  58.     virtual TQ3GroupObject        GetModel(void);
  59.     virtual void                SetCamera( TQ3CameraObject inGroup );
  60.     virtual TQ3CameraObject        GetCamera(void);
  61.     virtual void                SetLights( TQ3GroupObject inGroup );
  62.     virtual TQ3GroupObject        GetLights(void);
  63.     virtual void                SetDefaultAttributes(TQ3AttributeSet inAttributes);
  64.     virtual TQ3AttributeSet     GetDefaultAttributes(void);
  65.     virtual void                SetViewHints(TQ3ViewHintsObject inHints);
  66. //    virtual TQ3ViewHintsObject    GetViewHints(void);
  67.     
  68.     virtual void CalcBoundingBox(TQ3BoundingBox &outBox, 
  69.                     TQ3ComputeBounds inComputeBounds = kQ3ComputeBoundsApproximate);
  70.     virtual void Write( TQ3FileObject inFile );
  71.  
  72.     static    void    FatalErrorSeen() { sSawFatalError = true; }
  73.     
  74. protected:
  75.     virtual TQ3ViewObject    GetView();
  76.     
  77.     // Style accessors
  78.     // Override to change these styles.
  79.     virtual TQ3InterpolationStyle GetInterpolationStyle() 
  80.                         { return kQ3InterpolationStyleNone; }
  81.     virtual TQ3BackfacingStyle GetBackfacingStyle() 
  82.                         { return kQ3BackfacingStyleBoth; }
  83.     virtual TQ3FillStyle GetFillStyle() 
  84.                         { return kQ3FillStyleFilled; }
  85.     
  86.     // Rendering
  87.     virtual void    DrawSelf();
  88.     virtual void    ResizeFrameBy(Int16 inWidthDelta, Int16 inHeightDelta,
  89.                                     Boolean inRefresh);
  90.     virtual void    MoveBy(Int32 inHorizDelta, Int32 inVertDelta,
  91.                                     Boolean inRefresh);
  92. protected:
  93.     virtual TQ3Status    SubmitScene();
  94.     
  95.         // adjust the camera to the frame size
  96.     virtual void    AdjustQ3ViewToFrame();
  97.     
  98. protected:
  99.     TQ3ViewObject    mView ;                    // the view for the scene
  100.     TQ3GroupObject    mModel ;                // object in the scene being modelled
  101.     TQ3GroupObject    mLights ;
  102.     TQ3CameraObject    mCamera ;
  103.     TQ3DrawContextObject    mDrawContext;
  104.     TQ3RendererObject        mRenderer;
  105.     TQ3AttributeSet            mDefaultAttributes;
  106.     TQ3StyleObject    mInterpolation ;        // interpolation style used when rendering
  107.     TQ3StyleObject    mBackFacing ;            // whether to draw shapes that face away from the camera
  108.     TQ3StyleObject    mFillStyle ;            // whether drawn as solid filled object or decomposed to components
  109.     
  110.     static Boolean    sSawFatalError;            // Stop processing when there is a fatal error
  111.     static Boolean    sNowSubmitting;            // Keep submitting loops from being reentrant.
  112. };
  113.  
  114. class StSubmittingSetter {
  115. public:
  116.     StSubmittingSetter() 
  117.         { Assert_( !CQD3DPane::sNowSubmitting ); CQD3DPane::sNowSubmitting = true; }
  118.     ~StSubmittingSetter() 
  119.         { CQD3DPane::sNowSubmitting = false; }
  120. };
  121.  
  122.